package com.lam.common.base.domain;

import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lam.common.constant.CommonConstant;

/**
 * 登录用户信息
 */
public class LoginUser implements UserDetails {
	
	private static final long serialVersionUID = 1L;
	
	/** 商城ID */
	private String shopId;
	
	/** 记住我 */
	private boolean rememberMe;
	
	/** 用户ID */
	private String userId;
	
	/** 部门ID */
	private String deptId;

	/** 登录人账号 */
	private String username;
	
	/** 注册登录方式（1-手机号，2-邮箱，3-账号密码） */
	private Integer regType;
    
	/** 真实姓名账号 */
	private String realname;

	/** 用户昵称 */
	private String nickName;

	/** 头像 */
	private String avatar;

	/** 性别（1：男 2：女） */
	private Integer sex;

	/** 电子邮件 */
	private String email;

	/** 电话 */
	private String phone;

	/** 状态(1：正常 2：禁用） */
	private String status;
	/** 职务，关联职务表 */
	private String post;
	/** 工号 */
    private String workNo;
    
    /** 用户类型(1前端，2后端，3前端和后端，0禁止登陆) */
    private Integer userType;
    
    /** 是否新用户(1是，0否) */
    private Integer isNew;
    /** 备注 */
    private String remark;
    
    private String authType;
    /** 用户唯一标识 */
	private String token;
	/** 登陆时间 */
	private Long loginTime;
	/** 有效时长 */
	private Long expireTime;
	/** 过期时间 */
	private Long expiresAt;
	/** token有效时长 */
	private Long tokenExpires;
	
    /** 登录IP地址 */
	private String ipaddr;
	/** 登录地点 */
	private String loginLocation;
	/** 浏览器类型 */
	private String browser;
	/** 操作系统 */
	private String os;
	/** 机器码 */
    private String machineCode;
    
    @Override
	public String getPassword() {
		return null;
	}

	@Override
	public String getUsername() {
		return username;
	}

	/**
	 * 账户是否未过期,过期无法验证
	 */
	@JsonIgnore
	@Override
	public boolean isAccountNonExpired() {
		return isEnabled();
	}

	/**
	 * 指定用户是否解锁,锁定的用户无法进行身份验证
	 * 
	 * @return
	 */
	@JsonIgnore
	@Override
	public boolean isAccountNonLocked() {
		return isEnabled();
	}

	/**
	 * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
	 * 
	 * @return
	 */
	@JsonIgnore
	@Override
	public boolean isCredentialsNonExpired() {
		return isEnabled();
	}

	/**
	 * 是否可用 ,禁用的用户不能身份验证
	 * 
	 * @return
	 */
	@JsonIgnore
	@Override
	public boolean isEnabled() {
		return CommonConstant.STATUS_NORMAL.equals(status);
	}
	
	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return null;
	}
	
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getDeptId() {
		return deptId;
	}
	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getNickName() {
		return nickName;
	}
	public void setNickName(String nickName) {
		this.nickName = nickName;
	}
	public String getAvatar() {
		return avatar;
	}
	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getPost() {
		return post;
	}
	public void setPost(String post) {
		this.post = post;
	}
	public String getWorkNo() {
		return workNo;
	}
	public void setWorkNo(String workNo) {
		this.workNo = workNo;
	}
	public Integer getUserType() {
		return userType;
	}
	public void setUserType(Integer userType) {
		this.userType = userType;
	}
	public Integer getIsNew() {
		return isNew;
	}
	public void setIsNew(Integer isNew) {
		this.isNew = isNew;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getAuthType() {
		return authType;
	}
	public void setAuthType(String authType) {
		this.authType = authType;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public Long getLoginTime() {
		return loginTime;
	}
	public void setLoginTime(Long loginTime) {
		this.loginTime = loginTime;
	}
	public Long getExpireTime() {
		return expireTime;
	}
	public void setExpireTime(Long expireTime) {
		this.expireTime = expireTime;
	}
	public Long getExpiresAt() {
		return expiresAt;
	}
	public void setExpiresAt(Long expiresAt) {
		this.expiresAt = expiresAt;
	}
	public String getIpaddr() {
		return ipaddr;
	}
	public void setIpaddr(String ipaddr) {
		this.ipaddr = ipaddr;
	}
	public String getLoginLocation() {
		return loginLocation;
	}
	public void setLoginLocation(String loginLocation) {
		this.loginLocation = loginLocation;
	}
	public String getBrowser() {
		return browser;
	}
	public void setBrowser(String browser) {
		this.browser = browser;
	}
	public String getOs() {
		return os;
	}
	public void setOs(String os) {
		this.os = os;
	}
	public String getMachineCode() {
		return machineCode;
	}
	public void setMachineCode(String machineCode) {
		this.machineCode = machineCode;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public boolean isRememberMe() {
		return rememberMe;
	}

	public void setRememberMe(boolean rememberMe) {
		this.rememberMe = rememberMe;
	}

	public Long getTokenExpires() {
		return tokenExpires;
	}

	public void setTokenExpires(Long tokenExpires) {
		this.tokenExpires = tokenExpires;
	}

	public Integer getRegType() {
		return regType;
	}

	public void setRegType(Integer regType) {
		this.regType = regType;
	}

	public String getShopId() {
		return shopId;
	}

	public void setShopId(String shopId) {
		this.shopId = shopId;
	}

}
